#include <NewSoftSerial.h>
#include <uMMC.h>

NewSoftSerial ummc_s(4, 5);

uMMC ummc1(ummc_s);

void setup()
{
  pinMode(13, OUTPUT);

  Serial.begin(9600);

  ummc_s.begin(9600);
}

void loop()
{
  char filename[64];

  Serial.println("Initializing uMMC");

  // prepares the communications with the uMMC and closes all open files (if any)
  ummc1.sync();
  
  Serial.print("uMMC Version: ");
  Serial.println(ummc1.version());

  // list all files

  Serial.print("File count: ");
  
  Serial.println(ummc1.filecount("/", "*"), DEC);

  Serial.println("--- Files ---");

  ummc1.opendir("/");

  while(ummc1.readdir(filename, "*") == 0)
  {
    Serial.println(filename);
  }

  Serial.println("-------------");

  while(1);  // just loop infinitely here at the end, wait for reset
}
